<?php

namespace App\Models\Wechat;

use Illuminate\Database\Eloquent\Model;

use Cache;

class Text extends Model
{
    protected $table = 'wechat_text';

    //缓存过期时间
    protected $cacheTime = 86400*7;

    public function cacheFind($id){
    	$text = Cache::get(config('app.name').':text:'.$id);
    	if(!$text){
    		$text = $this->find($id);
    		if(!$text){
    			return false;
    		}
    		Cache::put(config('app.name').':text:'.$id, $text,$this->cacheTime);
    	}
    	return $text;
    }

    public function cacheEmpty($id){
        Cache::forget(config('app.name').':text:'.$id);
        return $this;
    }
}
